package com.heima.wemedia.controller.admin;

import com.heima.model.admin.dtos.NewsAuthDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.wemedia.service.WmNewsFeignService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("admin用的自媒体审核")
@Slf4j
@RestController
@RequestMapping
public class WmNewsFeignController {

    @Autowired
    private WmNewsFeignService wmNewsFeignService;

    /**
     * 文章列表查询
     * @param dto 请求参数
     * @return 查询结果
     */
    @PostMapping("/api/v1/news/list_vo")
    ResponseResult listNews(@RequestBody NewsAuthDto dto) {
        log.info("服务方接到管理端发来的请求参数：{}", dto);
        return wmNewsFeignService.listNews(dto);
    }

    //文章 查看详情
    @GetMapping("/api/v1/news/one_vo/{id}")
    ResponseResult getNewsDetail(@PathVariable Integer id) {
        log.info("服务方接到管理端发来的请求查询详情：{}", id);
        return wmNewsFeignService.getNewsDetail(id);
    }


    //文章人工审核 拒绝
    @PostMapping("/api/v1/news/auth_fail")
    ResponseResult auth_fail(@RequestBody NewsAuthDto dto) {
        log.info("服务方接到管理端发来的人工审核后的拒绝参数：{}", dto);
        return wmNewsFeignService.auth_fail(dto);
    }

    //文章人工审核 成功
    @PostMapping("/api/v1/news/auth_pass")
    ApArticle authPass(@RequestBody NewsAuthDto dto) {
        return wmNewsFeignService.authPass(dto);
    }







    //人工审核 用户通过 新增
    @PostMapping("/api/v1/auth/pass")
    ResponseResult addWmUser(ApUser apUser){
        return wmNewsFeignService.addWmUser(apUser);
    }
}
